home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 701-725 / 708 / intuisup / intuisup42.lha / Intuisup / source.lha / Render / render_test.c < prev    next >
C/C++ Source or Header  |  1992-04-30  |  4KB  |  148 lines

  1. /* $Revision Header *** Header built automatically - do not edit! ***********
  2.  *
  3.  *    (C) Copyright 1991 by Torsten Jürgeleit
  4.  *
  5.  *    Name .....: render_test.c
  6.  *    Created ..: Thursday 19-Dec-91 15:14:45
  7.  *    Revision .: 0
  8.  *
  9.  *    Date        Author                 Comment
  10.  *    =========   ====================   ====================
  11.  *    30-Apr-92   Torsten Jürgeleit      raster for clear_window()
  12.  *    19-Dec-91   Torsten Jürgeleit      Created this file!
  13.  *
  14.  ****************************************************************************
  15.  *
  16.  *    Test of render and window functions
  17.  *
  18.  * $Revision Header ********************************************************/
  19.  
  20.     /* Includes */
  21.  
  22. #include <exec/types.h>
  23. #include <graphics/gfxbase.h>
  24. #include <graphics/text.h>
  25. #include <exec/types.h>
  26. #include <intuition/intuition.h>
  27. #ifdef AZTEC_C
  28. #include <functions.h>   /* needed for Aztec C - prototypes and pragmas for all Amiga system functions */
  29. #endif
  30. #include <libraries/memwatch.h>   /* header file for memory debug link library (Fish 240) - AFTER functions.h */
  31. #include <string.h>
  32. #include "render.h"
  33.  
  34.     /* Defines */
  35.  
  36. #define WINDOW_WIDTH        600
  37. #define WINDOW_HEIGHT        180
  38. #define WINDOW_IDCMP        CLOSEWINDOW
  39. #define WINDOW_FLAGS        (WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE)
  40. #define WINDOW_TITLE        (UBYTE *)" Render test "
  41.  
  42. #define RENDER_INFO_FLAGS    (USHORT)(RENDER_INFO_FLAG_INNER_WINDOW | RENDER_INFO_FLAG_BACK_FILL)
  43. #define OPEN_WINDOW_FLAGS    (USHORT)(OPEN_WINDOW_FLAG_CENTER_WINDOW | OPEN_WINDOW_FLAG_RENDER_PENS)
  44.  
  45. #define RASTER_WIDTH        20
  46. #define RASTER_HEIGHT        10
  47.  
  48.     /* Globals */
  49.  
  50. struct IntuitionBase  *IntuitionBase;
  51. struct GfxBase        *GfxBase;
  52. struct Library        *DiskfontBase;
  53.  
  54.     /* Statics */
  55.  
  56. STATIC struct NewWindow  test_new_window = {
  57.    0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0, 0, WINDOW_IDCMP, WINDOW_FLAGS,
  58.    NULL, NULL, WINDOW_TITLE, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
  59. };
  60. STATIC struct TextAttr  topaz60_attr = { (STRPTR)"topaz.font", TOPAZ_SIXTY,
  61.                            FS_NORMAL, FPF_ROMFONT };
  62. STATIC struct IntuiText  itexts[] = {
  63.    {
  64.     0, 0, JAM1, (WINDOW_WIDTH - 10 * 10) / 2, (WINDOW_HEIGHT - 6 * 8) / 2,
  65.     &topaz60_attr, (UBYTE *)"Text pen 1", &itexts[1]
  66.    }, {
  67.     0, 0, JAM1, (WINDOW_WIDTH - 10 * 10) / 2, (WINDOW_HEIGHT + 4 * 8) / 2,
  68.     &topaz60_attr, (UBYTE *)"Text pen 2", NULL
  69.    }
  70. };
  71.     /* Prototypes */
  72.  
  73. VOID test_action(struct RenderInfo  *ri, struct Window  *win);
  74.  
  75.     /* Pragmas */
  76.  
  77. #pragma regcall(test_action(a0,a1))
  78.  
  79.     /* Render test */
  80.  
  81.    LONG
  82. main(VOID)
  83. {
  84.    struct RenderInfo  *ri;
  85.    struct Window      *win;
  86.  
  87.    MWInit((BPTR)NULL, 0L);
  88.    if (IntuitionBase = OpenLibrary("intuition.library", 0L)) {
  89.       if (GfxBase = OpenLibrary("graphics.library", 0L)) {
  90.      if (DiskfontBase = OpenLibrary("diskfont.library", 0L)) {
  91.         if (ri = get_render_info(NULL, RENDER_INFO_FLAGS)) {
  92.            if (win = open_window(ri, &test_new_window,
  93.                                OPEN_WINDOW_FLAGS)) {
  94.           test_action(ri, win);
  95.           close_window(win, FALSE);
  96.            }
  97.            free_render_info(ri);
  98.         }
  99.         CloseLibrary(DiskfontBase);
  100.      }
  101.      CloseLibrary(GfxBase);
  102.       }
  103.       CloseLibrary(IntuitionBase);
  104.    }
  105.    MWTerm();
  106.    return(0L);
  107. }
  108.     /* Perform IDCMP action */
  109.  
  110.    VOID
  111. test_action(struct RenderInfo  *ri, struct Window  *win)
  112. {
  113.    struct RastPort  *rp = win->RPort;
  114.    struct MsgPort   *up = win->UserPort;
  115.    struct Image     *image = &ri->ri_Images[0];
  116.    ULONG  left_edge = 40;
  117.    USHORT i;
  118.    BOOL   keepon = TRUE;
  119.  
  120.    /* Draw raster around inner area */
  121.    clear_window(ri, win, 0, 0, -1, -1, CLEAR_WINDOW_FLAG_USE_RASTER);
  122.    clear_window(ri, win, RASTER_WIDTH, RASTER_HEIGHT, WINDOW_WIDTH -
  123.             2 * RASTER_WIDTH, WINDOW_HEIGHT - 2 * RASTER_HEIGHT, 0);
  124.    /* Init and print intui texts */
  125.    itexts[0].FrontPen = ri->ri_TextPen1;
  126.    itexts[1].FrontPen = ri->ri_TextPen2;
  127.    PrintIText(rp, &itexts[0], 0L, 0L);
  128.  
  129.    /* Print render images */
  130.    for (i = 0; i < MAX_RENDER_IMAGES; i++, image++, left_edge += 50) {
  131.       DrawImage(rp, image, left_edge, (LONG)((WINDOW_HEIGHT -
  132.                 (2 * image->TopEdge + image->Height)) / 2));
  133.    }
  134.  
  135.    /* Waiting for close window event */
  136.    do {
  137.       struct IntuiMessage  *msg;
  138.  
  139.       WaitPort(up);
  140.       while (msg = (struct IntuiMessage *)GetMsg(up)) {
  141.      if (msg->Class == CLOSEWINDOW) {
  142.         keepon = FALSE;
  143.      }
  144.      ReplyMsg((struct Message *)msg);
  145.       }
  146.    } while (keepon == TRUE);
  147. }
  148.